package com.director.hibernate;

import com.director.core.ParameterFactory;
import org.hibernate.SessionFactory;

/**
 * @author Simone Ricciardi
 * @version 1.0, 10/16/2011
 */
public class MergeParameterFactory implements ParameterFactory {

   private SessionFactory sessionFactory;

   public MergeParameterFactory(SessionFactory sessionFactory) {
      this.sessionFactory = sessionFactory;
   }

   @Override
   public Class getInputType() {
      return Object.class;
   }

   @Override
   public Object create(Class type, Object input) {
      return this.sessionFactory.getCurrentSession().merge(input);
   }
}
